package ru.geyes.screw.random;

import java.util.Random;

/**
 * @author alex
 *         date 17.05.2008
 *         time 21:21:57
 */
public class RandomUtils {
    private static Random random = new Random();

    public static long getLong() {
        return random.nextLong();
    }

    public static int getInt() {
        return random.nextInt();
    }

    public static long getInt(int n) {
        return random.nextInt(n);
    }

    public static String getString(String alphabet, int count) {
        if (count < 0) throw new IllegalArgumentException("count must be grate then 0");
        char[] buf = new char[count];
        for (int i = 0; i < count; i++) {
            buf[i] = alphabet.charAt(random.nextInt(alphabet.length()));
        }
        return new String(buf);
    }


    private static final String DEFAULT_ALPHABET_LOW_CASE = "qwertyuiopasdfghjklzxcvbnm";
    private static final String DEFAULT_ALPHABET_UPPER_CASE = DEFAULT_ALPHABET_LOW_CASE.toUpperCase();
    private static final String DEFAULT_ALPHABET_NUMERIC_SYMBOLS = "0123456789";

    private static final String DEFAULT_ALPHABET = DEFAULT_ALPHABET_LOW_CASE + DEFAULT_ALPHABET_UPPER_CASE + DEFAULT_ALPHABET_NUMERIC_SYMBOLS;


    public static String getString(int count) {
        return getString(DEFAULT_ALPHABET, count);
    }

}
